package indy.test.indy;

import java.lang.invoke.CallSite;
import java.lang.invoke.ConstantCallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.invoke.MethodType;

public class IndyReuseTemplate {
    public static void test() {
       indy();
    }
    
    
    public static void test2() {
        indy();
    }
    
    private static void indy() {
        throw new AssertionError();
    }
    
    public static void main(String[] args) throws Throwable {
        test();
        test2();
    }
   
    private static void print() {
        System.out.println("hello");
    }
    
    private static final CallSite CALLSITE;
    static {
        MethodHandle target;
        try {
            target = MethodHandles.lookup().findStatic(IndyReuseTemplate.class, "print",
                    MethodType.methodType(void.class));
        } catch (NoSuchMethodException | IllegalAccessException e) {
           throw new AssertionError(e);
        }
        CALLSITE = new ConstantCallSite(target);
    }

    public static CallSite bsm(@SuppressWarnings("unused") Lookup lookup,
                               @SuppressWarnings("unused") String name,
                               @SuppressWarnings("unused") MethodType type) throws Throwable {
        return CALLSITE;
    }
}
